/*
 * @Author: intellectual-seeker 3336339701@qq.com
 * @Date: 2025-11-15 20:10:08
 * @LastEditors: intellectual-seeker 3336339701@qq.com
 * @LastEditTime: 2025-11-17 13:52:23
 * @FilePath: /code/lesson34/udp_echo_server/InetAddr.hpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#pragma once

#include <string>
using namespace std;
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>

class InetAddr
{
    void GetAddress(string* ip, uint16_t* port)
    {
        *port = ntohs(_addr.sin_port);
        *ip = inet_ntoa(_addr.sin_addr);
    }
public: 
    InetAddr(struct sockaddr_in addr)
        :_addr(addr)
    {}

    string Ip()
    {
        return _ip;
    }

    uint16_t Port()
    {
        return _port;
    }

    ~InetAddr()
    {}

private:
    string _ip;
    uint16_t _port;
    struct sockaddr_in _addr;
};